package com.example.japinhands.ui.screen

import androidx.compose.foundation.background
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import com.example.japinhands.data.Word
import com.example.japinhands.data.WordConstant

@Composable
fun JapaneseWordCardTest(
    word: Word,
//    sentence: String,
    onClick: () -> Unit
) {
    Box(
        modifier = Modifier
            .fillMaxWidth()
            .padding(2.dp)
            .background(color = Color(0xFF2C3E50), shape = RoundedCornerShape(8.dp))
            .clickable(onClick = onClick)
    ) {
        Row(
            modifier = Modifier
                .fillMaxWidth()
                .align(Alignment.TopEnd),
            verticalAlignment = Alignment.Top,
        ) {
            Spacer(modifier = Modifier.weight(1f))
            Box(
                modifier = Modifier.background(
                    color = Color(0x40FFFFFF),
                    shape = RoundedCornerShape(topEnd = 8.dp)
                )
            ) {
                Text(
                    modifier = Modifier.padding(2.dp),
                    text = WordConstant.getWordType(word.type),
                    color = Color.White,
                    fontWeight = FontWeight.Bold,
                    fontSize = 12.sp
                )
            }
        }
        Column(modifier = Modifier.padding(16.dp)) {
            Text(
                text = word.kanji,
                modifier = Modifier
                    .align(Alignment.CenterHorizontally)
                    .padding(bottom = 16.dp),
                style = TextStyle(fontSize = 32.sp, fontWeight = FontWeight.Bold)
            )
            Spacer(modifier = Modifier.height(16.dp))
            Text(text = "假名：${word.gana}")
            Spacer(modifier = Modifier.height(16.dp))
            Text(text = "中文翻译：${word.meaning}")
            Spacer(modifier = Modifier.height(8.dp))
            Text(text = "注意点：${word.notice}")
            Spacer(modifier = Modifier.height(8.dp))
            Text(text = "例句：${word.sentenceContent}")
            Spacer(modifier = Modifier.height(8.dp))
        }
    }
}
